//
//  main.m
//  字符串处理1
//
//  Created by blue on 16/4/10.
//  Copyright (c) 2016年 zzn. All rights reserved.
//

#import <Foundation/Foundation.h>

/*
 1 字符串的初始化方法：
   NSString *str1 = @"One";
   NSString *str2 = [NSString stringWithFormat:@"one"];
 
 2 unichar : unsigned int 无符号整型
 
 */


int main(int argc, const char * argv[]) {
    @autoreleasepool {
        
        
        NSString *str2 = [NSString stringWithUTF8String:"OneNSString!!"];
        
        
        //格式化字符串:常用于拼接字符串
        NSString *str3 = [NSString stringWithFormat:@"%@%d",@"Two",2];
        
        //必须手动使用release释放内存
        NSString *str6 = [[NSString alloc]initWithFormat:@"%@,%@",@"one",@"two"];
        
        unichar ch= [str6 characterAtIndex:2];
        NSLog(@"%@", [str6 substringWithRange:NSMakeRange(3, 4)]);
       
       /* NSComparisonResult res =[str3 compare:str2];
        if(res==NSOrderedAscending){
            NSLog(@"str3小于str2");
        }else if(res == NSOrderedSame){
            NSLog(@"str3==str2");
        }else{
            NSLog(@"str3>str2");
        }*/
       
     /*NSRange  range = [str6 rangeOfString:@"two"];
        if(range.location == NSNotFound){
            NSLog(@"没有找到字串,location=%li",NSNotFound);
        }else{
            NSLog(@"%@",NSStringFromRange(range));
        }
        */
        NSString *str1 = @"123";//字符串常量
        int  i= [str1 intValue];
        double j = [str1 doubleValue];
        float k = [str1 length];
        [str6 hasPrefix:@"one"];
        
        
        NSString *str7=@"one I am a student one!!!!";
        NSRange range = [str7 rangeOfString:@"a"];
        NSLog(@"%li,%li",range.location,range.length);
    
    }
    return 0;
}
